package GUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;

import Core.Connection;
import Core.SessionData;

/*
 * Made By: Kudinov Roma
 * 2013
 * 
 */
public class MainWindow extends JFrame
{
	private static final long serialVersionUID = 1L;

	private static AbstractMenu cur_menu = null;
	
	public static SessionData data;
	
	public JTextArea notification;
	public JButton notificationButton;
	
	public void removeNotification()
	{
		notification.setVisible(false);
		notificationButton.setVisible(false);
		repaint();
		
	}
	public void notification(String msg)
	{
		notification.setText("Notification:\n" + msg);
		notification.setVisible(true);
		notificationButton.setVisible(true);
		repaint();
	}
	
	public MainWindow()
	{
		super("Interactive Forum - Client v3.0");
		data = new SessionData();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		getContentPane().setLayout(null);
		this.setSize(800,600);
		setVisible(true);
		setResizable(false);
		notification = null;
		cur_menu = new ConnectMenu(this);
		cur_menu.create();

		notification = new JTextArea("Notification:\n");
		notification.setBounds(20, 300, 250, 100);
		this.getContentPane().add(notification);
		notification.setEditable(false);
		notification.setBackground(new Color(210, 210, 210));
		notification.setBorder(new LineBorder(Color.BLACK, 2));
		notification.setVisible(false);
		notificationButton = new JButton("X");
		notificationButton.setBounds(225, 280, 45,20);
		this.getContentPane().add(notificationButton);
		notificationButton.setVisible(false);
		notificationButton.addActionListener(new ActionListener() 
		{
            public void actionPerformed(ActionEvent e)
            {
            	removeNotification();
            }
		});

		//repaint();
		//cur_menu.destroy();
	}
	
	public static void switchMenu(AbstractMenu menu)
	{
		if(cur_menu != null) cur_menu.destroy();
		cur_menu = menu;
		menu.create();
	}
	
	public static AbstractMenu getMenu()
	{
		return cur_menu;
	}
	
	public static void main(String[] args) 
	{	
		new MainWindow();
		
	}

}
